extends Node2D
@onready var viewrect:Rect2  = get_viewport_rect()
@onready var timer:Timer = $Timer
@onready var POINT_TIMER:Timer = $Timer
var gameOverTip:PackedScene = preload("res://scn/tip/game_over.tscn")
# 切换场景速度
var INTERNAL_VARIABLE = 42


# Called when the node enters the scene tree for the first time.
func _ready():
	await SceneManager.scene_loaded
	$CharacterBody2D.game_over.connect(gameOverHandle)
	jumpLevel()
	pass # Replace with function body.

func jumpLevel():
	(func():
		var sceneLevel = GlobalConstant.SCENE_MAP.get(2)
		POINT_TIMER.timeout.connect(func():
			GlobalConstant.changeScene(sceneLevel.get("scene"),INTERNAL_VARIABLE)	
		)
		POINT_TIMER.wait_time = sceneLevel.get("time")
		POINT_TIMER.start()
	).call_deferred()

# Called every frame. 'delta' is the elapsed time since the previous frame.
func _process(delta):
	pass
	
func gameOverHandle():
	var gameOverLabel = gameOverTip.instantiate()
	var labelSize = Vector2(180,50)
	gameOverLabel.position = viewrect.size / 2 - labelSize / 2
	add_child(gameOverLabel)
